#-*- coding:utf-8 -*-
import requests
import os

url = 'https://123.207.254.6:8081/cas/captcha.jpg'

header = {
	'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36',
	'Cookie': 'HttpOnly; JSESSIONID=6CA898903C7BCB44CD5BC87D20ED2485',
	'Host': '123.207.254.6:8081',
}

proxies = {'https':'https://127.0.0.1:12759'}

def download_jpg(n):
	i = 15000
	while i < n:
		i += 1
		res = requests.get(url,headers=header,proxies=proxies,verify=False)
		if res:
			path = 'authcode'
			if not os.path.exists(path):
				os.makedirs(path)
			file_path = os.path.join(os.getcwd(),path)
			save_jpg(res.content,file_path+'\\'+str(i)+'.jpg')
		else:
			print('获取失败')

def save_jpg(data,file_path):
	with open(file_path,'wb') as fp:
		fp.write(data)



if __name__ == '__main__':
	# save_jpg('11','test.jpg')
	download_jpg(20000)
